﻿using System;
using AllInOnePluginBL.Helpers;

public partial class RegisterForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    
    protected void CreateUserButton_Click(object sender, EventArgs e)
    {
        var pluginDBHandler = PluginDBHandler.Instance;

        if (pluginDBHandler.IsUserNameExists(this.Email.Text))
        {
            UserExistsValidator.IsValid = false;
            return;
        }
        var user = pluginDBHandler.CreateUser(this.Email.Text, this.Password.Text);
        var mailSender = new MailSender();
        if(!mailSender.SendConfirmationMail(user.UserID, user.UserName, user.UserUniqeGuid))
        {
            SendMailFailedValidator.IsValid = false;
            //SendMailFailedValidator.ErrorMessage = "";
            return;
        }
        emailSentMessage.Visible = true;
        //Response.Redirect("~\\Main.aspx");
    }
    protected void EmailRequired_DataBinding(object sender, EventArgs e)
    {

    }
}